package com.orange.cepappmanager.java.model;
import java.io.Serializable;
import java.util.HashMap;

import javax.persistence.Entity;
import javax.persistence.Id;
@Entity
public class Phone implements Serializable {


	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	@Id
	private String id;
	private String name;
	private String status;
	private HashMap<String, String> rules;

	public Phone() {
		name = "";
		id = "";
		status = "";
		this.rules = new HashMap<String, String>();
	}

	public Phone(String name, String id, String status) {
		this.name = name;
		this.id = id;
		this.status = status;
		this.rules = new HashMap<String, String>();
	}

	public void addRule(String name, String rule) {
		rules.put(name, rule);
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getId() {
		return this.id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String[] getRules() {
		String[] r = new String[this.rules.size()];
		int i=0;
		for (String s : rules.keySet())
			r[i++] = s + "|" + rules.get(s);
		return r;
	}

	public void setRules(HashMap<String, String> rules) {
		this.rules = rules;
	}

	public void deleteRule(String name) {
		rules.remove(name);
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}
	
	public String toString() {
			        StringBuffer sb = new StringBuffer();
			        sb.append("Id: ").append(getId());
			        sb.append(" - Name: ").append(getName());
			        sb.append(" - Status: ").append(getStatus());
			        return sb.toString();
			    }

}
